/**
 * Created by hhshi on 13-10-23.
 */
var user_model = require('../model/user');
/*
 * GET home page.
 */

exports.index = function(req, res){
  res.render('index', { title: '网盘登录' });
};

/**
 * 检测用户登录
 * @param req
 * @param res
 */
exports.checkLogin = function(req, res){
    var user = {
        name : req.body.name,
        password : req.body.password
    };
    user_model.getUser(user.name,user.password,function(results){
        var result = {};
        if(results.length > 0 ){
            //req.session.name = user.name;
           // req.session.uid = results[0]['id'];
            result = results[0];
            result.statuscode = "200";
        }else{
            result.statuscode = "400";
        }
        res.json(result);
    });
};